import { FC } from 'react';
import { Button, Popconfirm } from 'antd';
import { TableActionConfirm } from '../interface';

export const ConfirmAction: FC<TableActionConfirm> = ({ text, confirm, disable, loading }) => {
  const { title = `确认执行${text}操作吗？`, onClick } = confirm;

  return (
    <Popconfirm title={title} onConfirm={onClick} disabled={disable}>
      <Button type="link" size="small" disabled={disable} loading={loading}>
        {text}
      </Button>
    </Popconfirm>
  );
};
